package com.fdd;
import com.fdd.dao.BookDao;
import com.fdd.service.BookService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

// 测试自动装配，在配置文件中设置bookService这个bean，并且为之创建setter方法。
public class App {
    public static void main(String[] args) {
        System.out.println("Hello World!");
        //获取IOC容器 ApplicationContext
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        ctx.registerShutdownHook();
        // BookDao bookDao = (BookDao)ctx.getBean("bookDao1");
        // bookDao.save();

        BookService bookService = (BookService)ctx.getBean("bookService");
        bookService.save();

        //ctx.close();
    }
}
